import java.net.*;


public class Listener extends Thread{
	public ServerSocket server;
	int port;
	myRouter router = null;
	
	public Listener(int port, myRouter mr) {
		this.setDaemon(true);
		this.port = port;
		router = mr;
	}
	
	public void run() {
		try {
			server = new ServerSocket(port);
			router.setLocalIP(InetAddress.getLocalHost().getHostAddress());
			while (true) {
				Socket client = server.accept();
				new Thread(new newServer(client, router)).start();
				Thread.sleep(50);
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
